package com.zg.scf.web;

import com.zg.common.core.R;
import com.zg.common.core.dao.scf.entity.ImgConfig;
import com.zg.scf.domain.req.img.ImgConditionAddReq;
import com.zg.scf.domain.req.img.ImgConfigAddReq;
import com.zg.scf.domain.vo.ImgConfigVo;
import com.zg.scf.service.ImgConditionService;
import com.zg.scf.service.ImgConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * DESCRIPTION
 *
 * @author zhanfeng.liang
 * @since 2025-07-25
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/img/config")
@Slf4j
@Api(tags = "画像配置")
public class ImgConfigController {

    private final ImgConfigService imgConfigService;
    @GetMapping("/getInfo")
    @ApiOperation(value = "查询平台配置")
    public R<ImgConfigVo> getInfo(@RequestParam Long configId) {
        ImgConfigVo vo =imgConfigService.getInfo(configId);
        return R.success(vo);
    }

    @GetMapping("/getInfoByCompanyId")
    @ApiOperation(value = "查询金融机构配置")
    public R<ImgConfigVo> getInfoByCompanyId(@RequestParam Long companyId) {
        ImgConfigVo vo =imgConfigService.getInfoByCompanyId(companyId);
        return R.success(vo);
    }

    @PostMapping("/addCondition")
    @ApiOperation(value = "新增平台配置")
    public R addCondition(@RequestBody @Valid ImgConfigAddReq addReq) {
        imgConfigService.addCondition(addReq);
        return R.success();
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增机构配置")
    public R add(@RequestBody @Valid ImgConfigAddReq addReq) {
        imgConfigService.add(addReq);
        return R.success();
    }
}
